import time
from selenium.webdriver.common.by import By
from selenium import webdriver
from urllib import response
import requests
from urllib.parse import urljoin

BASE_URL = 'https://login3.scrape.center/'
LOGIN_URL = urljoin(BASE_URL, '/api/login')
INDEX_URL = urljoin(BASE_URL, '/api/book')
USERNAME = 'admin'
PASSWORD = 'admin'

# requests方法
response_login = requests.post(LOGIN_URL, data={
    'username': USERNAME,
    'password': PASSWORD
})

token = response_login.json().get('token')

headers = {'Authorization': f'JWT {token}'}

for i in range(3):
    response_index = requests.get(INDEX_URL, headers=headers)
    print(f'response_status:{response_index.status_code}')
